package com.liqw;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

public class Constant {
    public static final String MODE_SPI = "spi";
    public static final String MODE_AUTO = "auto";
    public static final AtomicInteger STEP = new AtomicInteger(0);
    public static final Map<String, Integer> STEP_MAP = new ConcurrentHashMap<>();

    public static Integer getStep(String key) {
        Integer step = STEP_MAP.get(key);
        if (step == null) {
            step = STEP.getAndIncrement();
            STEP_MAP.put(key, step);
        }
        return step;
    }

    public static String getStepStr(String key) {
        return getStepStr(key, MODE_AUTO);
    }

    public static String getStepStr(String key, String mode) {
        return String.join("", "【", getStep(key).toString(), "】", mode, " ");
    }
}
